/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package forensicsGUI;

import javax.swing.JTextArea;
import javax.swing.JScrollPane;

/**
 *
 * @author marc
 */
public class ErrorInstanceLogger implements ILogDevice 
{
    private JTextArea tarea = new JTextArea("", JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    private int processIdentifier=0;
    public void InstanceLogger()
    {
        tarea.setText("");
        tarea.setEditable(false);
        tarea.setEnabled(false);
    }
    int getPid()
    {
        return processIdentifier;
    }
    /*
    public void log(String log)
    {
        tarea.append(log+"\n");
        System.out.println(log);
        tarea.updateUI();
    }*/
    
      public void log(char log)
    {
          int t=0;
        tarea.append(log + "");
        if ( (t = tarea.getText().indexOf("</pid>")) > 0)
        {
            String pid = tarea.getText();
            tarea.setText("");
            pid = pid.substring(5,t);
            processIdentifier = new Integer(pid).intValue();
        }
    }
    
    JTextArea getArea()
    {
        return tarea;
    }
    
}
